﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data;
using System.Drawing;

namespace binary
{
    static public class MyWidok
    {
        static public void setZuzyciePamieci(Label lbl)
        {
            lbl.Text = (GC.GetTotalMemory(true) / 1024 / 1024).ToString();
        }

        static public void setPredkoscZapisu(Label lbl,long FileSize, int Zaladowano, int LiczbaRekordow, TimeSpan Czas)
        {
            lbl.Text = String.Format("{0:N2} MB/s", (FileSize * (((double)Zaladowano / (double)LiczbaRekordow)) / 1024 / 1024 / (Czas.Seconds + Czas.Minutes * 60 + Czas.Hours * 3600)));
        }

        static public void setCzasCalkowity(Label lbl, TimeSpan Czas)
        {
            lbl.Text = Czas.Hours + "h. " + Czas.Minutes + "m. " + Czas.Seconds + "s.";
        }

        static public void setCzasTabeli(Label lbl, TimeSpan Czas)
        {
            lbl.Text = Czas.Minutes + "m. " + Czas.Seconds +"s.";
        }

        static public void setLiczbaRekordow(Label lbl, int Liczba)
        {
            lbl.Text = String.Format("{0:N0}", Liczba);
        }

        static public void setLabelValue(Label lbl, int Value)
        {
            lbl.Text = String.Format("{0:N0}",Value);
        }

        static public void setLabelValue(Label lbl, string Value)
        {
            lbl.Text = Value;
        }

        static public void setProgres(ProgressBar p, int Value, Label lbl)
        {
            p.Value = Value;
            lbl.Text = String.Format("{0:N2}%", (double)((double)Value / (double)p.Maximum) * 100);
        }

        static public void setProgresSettings(ProgressBar p, int Min, int Max)
        {
            p.Minimum = Min; p.Maximum = Max;
        }

        static public void setTableActive(DataGridView Grid, int Table)
        {
            for (int x = 0; x< Grid.Rows.Count; x++)
            {
                Grid.Rows[x].DefaultCellStyle.BackColor = Color.White;
            }
            Grid.Rows[Table].DefaultCellStyle.BackColor = Color.Lime;
        }

        static public void setLogNewData(List<MyBlad> Lista, DataGridView Grid)
        {
            Grid.DataSource = null;
            Grid.Refresh();
            Grid.DataSource = Lista;
            Grid.Refresh();
            Grid.Update();
        }

        static public void setInputValue(TextBox Text, string Value)
        {
            Text.Text = Value;
        }



    }
}
